package com.lagou.mr.sv;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortValueMapper extends Mapper<Object, Text, IntWritable, IntWritable> {

    IntWritable k = new IntWritable();

    @Override
    protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
        //1 每次读取一行文件数据，并将数据由字符串转化为int
        String line = value.toString();
        k.set(Integer.parseInt(line));

        //2 将键值对写入context中，v可以为任意整数
        context.write(k, new IntWritable(1));

    }
}
